home *** CD-ROM | disk | FTP | other *** search
/ PC World Interactive 7 / PC World Interactive 7.iso / program / vbkontrol.exe / NETC_13N.ZIP / DEMO.FRM (.txt) next >
Encoding:
Visual Basic Form  |  1995-06-14  |  13.0 KB  |  396 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "NetCode Demo"
  5.    ClientHeight    =   5370
  6.    ClientLeft      =   990
  7.    ClientTop       =   2595
  8.    ClientWidth     =   6090
  9.    FillColor       =   &H00808080&
  10.    FillStyle       =   0  'Solid
  11.    Height          =   5775
  12.    Icon            =   DEMO.FRX:0000
  13.    Left            =   930
  14.    LinkTopic       =   "Form1"
  15.    ScaleHeight     =   5370
  16.    ScaleWidth      =   6090
  17.    Top             =   2250
  18.    Width           =   6210
  19.    Begin ComboBox Fmt 
  20.       BackColor       =   &H00E0E0E0&
  21.       Height          =   288
  22.       Left            =   2160
  23.       Style           =   2  'Dropdown List
  24.       TabIndex        =   21
  25.       Top             =   1920
  26.       Width           =   1692
  27.    End
  28.    Begin SpinButton Spin1 
  29.       BackColor       =   &H00E0FFFF&
  30.       Height          =   252
  31.       Left            =   5760
  32.       SpinBackColor   =   &H00E0FFFF&
  33.       Top             =   2400
  34.       Width           =   252
  35.    End
  36.    Begin CheckBox CB_Intellicode 
  37.       BackColor       =   &H00C0C0C0&
  38.       Caption         =   " IntelliCode"
  39.       Height          =   372
  40.       Left            =   4080
  41.       TabIndex        =   18
  42.       Top             =   3480
  43.       Width           =   1452
  44.    End
  45.    Begin CheckBox CB_OverwriteFile 
  46.       BackColor       =   &H00C0C0C0&
  47.       Caption         =   " Overwrite"
  48.       ForeColor       =   &H00404040&
  49.       Height          =   372
  50.       Left            =   4080
  51.       TabIndex        =   17
  52.       Top             =   3840
  53.       Width           =   1212
  54.    End
  55.    Begin TextBox FileName 
  56.       BackColor       =   &H00E0FFFF&
  57.       Height          =   288
  58.       Left            =   3360
  59.       TabIndex        =   10
  60.       Top             =   3000
  61.       Width           =   2652
  62.    End
  63.    Begin PictureBox Picture1 
  64.       BackColor       =   &H00C0C0C0&
  65.       BorderStyle     =   0  'None
  66.       FillColor       =   &H00C0C0C0&
  67.       Height          =   495
  68.       Left            =   120
  69.       Picture         =   DEMO.FRX:0302
  70.       ScaleHeight     =   495
  71.       ScaleWidth      =   495
  72.       TabIndex        =   15
  73.       Top             =   360
  74.       Width           =   495
  75.    End
  76.    Begin CommandButton DecodedFileButton 
  77.       Caption         =   "..."
  78.       Height          =   252
  79.       Left            =   5520
  80.       TabIndex        =   9
  81.       Top             =   1440
  82.       Width           =   372
  83.    End
  84.    Begin CommandButton EncodedFileButton 
  85.       Caption         =   "..."
  86.       Height          =   252
  87.       Left            =   5520
  88.       TabIndex        =   7
  89.       Top             =   720
  90.       Width           =   372
  91.    End
  92.    Begin TextBox DecodedData 
  93.       Height          =   732
  94.       Left            =   1680
  95.       MultiLine       =   -1  'True
  96.       ScrollBars      =   2  'Vertical
  97.       TabIndex        =   8
  98.       Top             =   960
  99.       Width           =   3852
  100.    End
  101.    Begin OptionButton OB_Enc2String 
  102.       BackColor       =   &H00E0E0E0&
  103.       Caption         =   "EncodeToString"
  104.       Height          =   492
  105.       Left            =   480
  106.       TabIndex        =   0
  107.       Top             =   3720
  108.       Width           =   1680
  109.    End
  110.    Begin OptionButton OB_Enc2File 
  111.       BackColor       =   &H00E0E0E0&
  112.       Caption         =   "EncodeToFile"
  113.       Height          =   372
  114.       Left            =   480
  115.       TabIndex        =   1
  116.       Top             =   3360
  117.       Width           =   1572
  118.    End
  119.    Begin OptionButton OB_Dec2String 
  120.       BackColor       =   &H00E0E0E0&
  121.       Caption         =   "DecodeToString"
  122.       Height          =   372
  123.       Left            =   480
  124.       TabIndex        =   2
  125.       Top             =   2880
  126.       Width           =   1680
  127.    End
  128.    Begin OptionButton OB_Dec2File 
  129.       BackColor       =   &H00E0E0E0&
  130.       Caption         =   "DecodeToFile"
  131.       Height          =   492
  132.       Left            =   480
  133.       TabIndex        =   3
  134.       Top             =   2400
  135.       Width           =   1572
  136.    End
  137.    Begin OptionButton OB_Idle 
  138.       BackColor       =   &H00E0E0E0&
  139.       Caption         =   "Idle"
  140.       Height          =   492
  141.       Left            =   480
  142.       TabIndex        =   4
  143.       Top             =   2040
  144.       Value           =   -1  'True
  145.       Width           =   852
  146.    End
  147.    Begin Frame Frame1 
  148.       BackColor       =   &H00E0E0E0&
  149.       Caption         =   "Action"
  150.       Height          =   2412
  151.       Left            =   360
  152.       TabIndex        =   11
  153.       Top             =   1800
  154.       Width           =   1812
  155.       Begin Line Line1 
  156.          X1              =   0
  157.          X2              =   2280
  158.          Y1              =   1510
  159.          Y2              =   1510
  160.       End
  161.    End
  162.    Begin TextBox EncodedData 
  163.       Height          =   732
  164.       Left            =   1680
  165.       MultiLine       =   -1  'True
  166.       ScrollBars      =   2  'Vertical
  167.       TabIndex        =   6
  168.       Top             =   240
  169.       Width           =   3852
  170.    End
  171.    Begin Gauge Gauge1 
  172.       Autosize        =   -1  'True
  173.       BackColor       =   &H00FFC0C0&
  174.       ForeColor       =   &H00C00000&
  175.       Height          =   492
  176.       InnerBottom     =   5
  177.       InnerLeft       =   5
  178.       InnerRight      =   5
  179.       InnerTop        =   5
  180.       Left            =   240
  181.       Max             =   100
  182.       NeedleWidth     =   1
  183.       TabIndex        =   13
  184.       Top             =   4680
  185.       Width           =   5652
  186.    End
  187.    Begin NetCode NetCode1 
  188.       IntelliCode     =   -1  'True
  189.       Left            =   0
  190.       MaxFileSize     =   0
  191.       Overwrite       =   -1  'True
  192.       ProgressStep    =   1
  193.       Top             =   0
  194.    End
  195.    Begin Label FileCnt 
  196.       BackColor       =   &H00C0C0C0&
  197.       Height          =   252
  198.       Left            =   2760
  199.       TabIndex        =   20
  200.       Top             =   3840
  201.       Width           =   972
  202.    End
  203.    Begin Label L_MaxFSize 
  204.       Alignment       =   1  'Right Justify
  205.       BackColor       =   &H00C0C0C0&
  206.       Caption         =   "Maximum filesize"
  207.       Height          =   252
  208.       Left            =   3360
  209.       TabIndex        =   19
  210.       Top             =   2400
  211.       Width           =   2292
  212.    End
  213.    Begin Label Label4 
  214.       BackColor       =   &H00C0C0C0&
  215.       Caption         =   "Filename"
  216.       Height          =   252
  217.       Left            =   3360
  218.       TabIndex        =   12
  219.       Top             =   2760
  220.       Width           =   1092
  221.    End
  222.    Begin Label Done 
  223.       Alignment       =   2  'Center
  224.       BackColor       =   &H00C0C0C0&
  225.       Caption         =   "% Done"
  226.       Height          =   252
  227.       Left            =   2400
  228.       TabIndex        =   14
  229.       Top             =   4320
  230.       Width           =   1332
  231.    End
  232.    Begin Label Label2 
  233.       Alignment       =   2  'Center
  234.       BackColor       =   &H00C0C0C0&
  235.       Caption         =   "Encoded"
  236.       Height          =   252
  237.       Left            =   600
  238.       TabIndex        =   5
  239.       Top             =   360
  240.       Width           =   1092
  241.    End
  242.    Begin Label Label1 
  243.       Alignment       =   2  'Center
  244.       BackColor       =   &H00C0C0C0&
  245.       Caption         =   "Decoded"
  246.       Height          =   252
  247.       Left            =   600
  248.       TabIndex        =   16
  249.       Top             =   1080
  250.       Width           =   1092
  251.    End
  252. Option Explicit
  253. Dim Overwrite%, IntelliCode%, MaxFileSize&
  254. Const IDLE = 0
  255. Const DecodeToFile = 1
  256. Const EncodeToFile = 2
  257. Const DecodeToString = 3
  258. Const EncodeToString = 4
  259. Const UUEncode = 0
  260. Const Base64 = 1
  261. Const Quoted_Printable = 2
  262. Const UNCHECKED = 0
  263. Const CHECKED = 1
  264. Const VBERR_OUT_OF_MEMORY = 7
  265. Const VBERR_BAD_PROPERTY_VALUE = 380  ' // Index of error message for 'Invalid property value.'
  266. Const VBERR_BAD_ARRAY_INDEX = 381    ' // Index of property array out of bounds.
  267. Const VBERR_PROPERTY_READ_ONLY = 383
  268. Const VBERR_PROPERTY_WRITE_ONLY = 394
  269.                  
  270. Const NCERR_BEGIN_NOT_FOUND = 20001
  271. Const NCERR_SHORT_FILE = 20002      'uudecode...
  272. Const NCERR_NO_END = 20003            'uudecode didn't find the closing "end"
  273. Const NCERR_FILE_CREATE = 20004 'can't create for write (write protected ?)
  274. Const NCERR_FILE_OPEN = 20005  'can't open for read (doesn't exist?)
  275. Const NCERR_FILE_READ = 20006 'can't read from file
  276. Const NCERR_FILE_WRITE = 20007 'can't write to file (disk full?)
  277. Const NCERR_NO_FILENAME = 20008 'no filename given
  278. Const NCERR_FILE_EXISTS = 20009 'File exists and 'Overwrite' was On
  279. Const NCERR_NOT_ENOUGH_SPACE_IN_STRING = 20010 'the given pointer had not enought space to contain the output
  280. Const NCERR_NO_ENC_FILE = 20012 'No filename was given where to write the encoded data
  281. Const NCERR_NO_SUCH_FILENAME = 20017 'No such filename
  282. Const NCERR_NO_MORE_FILES = 20018 'No more files where to read from or write to
  283. Sub CB_Intellicode_Click ()
  284.   IntelliCode% = CB_Intellicode.Value
  285.   NetCode1.IntelliCode = IntelliCode%
  286. End Sub
  287. Sub CB_OverwriteFile_Click ()
  288.   Overwrite% = CB_OverwriteFile.Value '2=grayed not treated
  289.   NetCode1.Overwrite = Overwrite%
  290. End Sub
  291. Sub DoAction (Action As Integer)
  292.   On Error GoTo ErrorHandler
  293.   NetCode1.EncodedData = Form1.EncodedData
  294.   NetCode1.DecodedData = Form1.DecodedData
  295.   NetCode1.FileName = Form1.FileName
  296.   NetCode1.MaxFileSize = MaxFileSize&
  297.   NetCode1.Action = Action
  298.   Form1.FileName = NetCode1.FileName
  299.   Form1.DecodedData = NetCode1.DecodedData
  300.   Form1.EncodedData = NetCode1.EncodedData
  301.   If (NetCode1.FileCnt) Then
  302.     Form1.FileCnt.Caption = 1 + NetCode1.FileCnt & " Files"
  303.   Else
  304.     Form1.FileCnt.Caption = ""
  305.   End If
  306.   OB_Idle.Value = True
  307.   Exit Sub
  308. ErrorHandler:
  309.   Dim Msg As String
  310.   Select Case Err
  311.     Case VBERR_OUT_OF_MEMORY: Msg = "Out of memory"
  312.     Case VBERR_BAD_PROPERTY_VALUE: Msg = "Invalid property value"
  313.     Case VBERR_BAD_ARRAY_INDEX: Msg = "Index of property array out of bounds"
  314.     Case VBERR_PROPERTY_READ_ONLY: Msg = "Property read-only"
  315.     Case VBERR_PROPERTY_WRITE_ONLY: Msg = "Property write-only"
  316.     Case NCERR_BEGIN_NOT_FOUND: Msg = "The starting ""begin "" was not found"
  317.     Case NCERR_SHORT_FILE: Msg = "The input ended unexpectedly"
  318.     Case NCERR_NO_END: Msg = "The closing ""end"" was not found (uudecoded file may be too short)"
  319.     Case NCERR_FILE_CREATE: Msg = "Can't create a file (illegal filename or disk is write-protected)"
  320.     Case NCERR_FILE_OPEN: Msg = "Can't open for read the input file (file doesn't exist?)"
  321.     Case NCERR_FILE_READ: Msg = "Can't read from input file"
  322.     Case NCERR_FILE_WRITE: Msg = "Can't write to file (disk full?)"
  323.     Case NCERR_NO_FILENAME: Msg = "No filename was given while encoding"
  324.     Case NCERR_FILE_EXISTS: Msg = "File exists and Overwrite was set to FALSE"
  325.     Case NCERR_NOT_ENOUGH_SPACE_IN_STRING: Msg = "The given pointer had not enought space to contain the output (only when using the exported functions)"
  326.     Case NCERR_NO_ENC_FILE: Msg = "No filename was given where to write the encoded data"
  327.     Case NCERR_NO_SUCH_FILENAME: Msg = "No such filename"
  328.     Case NCERR_NO_MORE_FILES: Msg = "No more files where to read from or write to"
  329.     Case Else: Msg = "ERROR " & Err & " occurred."
  330.   End Select
  331.   MsgBox Msg  ' Display error message.
  332.   Resume Next ' Resume procedure.
  333. End Sub
  334. Sub Fmt_Click ()
  335.   NetCode1.Format = Fmt.ListIndex
  336. End Sub
  337. Sub Form_Load ()
  338.   If NetCode1.Overwrite Then
  339.     CB_OverwriteFile.Value = CHECKED
  340.   Else
  341.     CB_OverwriteFile.Value = UNCHECKED
  342.   End If
  343.   Overwrite% = CB_OverwriteFile.Value
  344.   IntelliCode% = True
  345.   NetCode1.IntelliCode = True
  346.   CB_Intellicode.Value = CHECKED
  347.   MaxFileSize& = (NetCode1.MaxFileSize + 100) / 200
  348.   MaxFileSize& = MaxFileSize& * 200
  349.   NetCode1.MaxFileSize = MaxFileSize&
  350.   L_MaxFSize.Caption = "Maximum filesize " & Str$(MaxFileSize&)
  351.   Fmt.AddItem "UUEncode", UUEncode
  352.   Fmt.AddItem "Base64", Base64
  353.   Fmt.AddItem "Quoted Printable", Quoted_Printable
  354.   Fmt.ListIndex = NetCode1.Format
  355. End Sub
  356. Sub NetCode1_Progress (PercentDone As Integer)
  357.    Gauge1.Value = PercentDone
  358.    Done.Caption = PercentDone & "% Done"
  359.    DoEvents
  360. End Sub
  361. Sub OB_Dec2File_Click ()
  362.   If NetCode1.Action = IDLE Then
  363.     DoAction (DecodeToFile)
  364.   End If
  365. End Sub
  366. Sub OB_Dec2String_Click ()
  367.   If NetCode1.Action = IDLE Then
  368.     DoAction (DecodeToString)
  369.   End If
  370. End Sub
  371. Sub OB_Enc2File_Click ()
  372.   If NetCode1.Action = IDLE Then
  373.     DoAction (EncodeToFile)
  374.   End If
  375. End Sub
  376. Sub OB_Enc2String_Click ()
  377.   If NetCode1.Action = IDLE Then
  378.     DoAction (EncodeToString)
  379.   End If
  380. End Sub
  381. Sub OB_Idle_Click ()
  382.   NetCode1.Action = IDLE
  383. End Sub
  384. Sub Spin1_SpinDown ()
  385.   If MaxFileSize& >= 10000 Then
  386.     MaxFileSize& = MaxFileSize& - 10000
  387.     L_MaxFSize.Caption = "Maximum filesize " & Str$(MaxFileSize&)
  388.   End If
  389. End Sub
  390. Sub Spin1_SpinUp ()
  391.   If MaxFileSize& < 2 ^ 31 - 10000 Then
  392.     MaxFileSize& = MaxFileSize& + 10000
  393.     L_MaxFSize.Caption = "Maximum filesize " & Str$(MaxFileSize&)
  394.   End If
  395. End Sub
  396.